<template>
  <tbody class="order-item">
    <tr class="order-info">
      <td style="padding-left: 10px;">{{value.create_time}}        订单号：{{value.order_no}}</td>
      <td></td>
      <td></td>
      <td></td>
      <td></td>
      <td style="padding-right: 10px;text-align: right">{{value.shop}}</td>
    </tr>
    <!-- 异常订单 -->
    <tr v-if="value.product.length === 0">
      <td></td>
      <td></td>
      <td></td>
      <td></td>
      <td style="text-align: center;">
        {{value.status == 0 ? '待付款' : value.status == 1 ? '待发货' : value.status == 2 ? '待收货' : value.status == 3 ? '待评价' : '无效商品'}}
      </td>
      <td style="text-align: center;">
        <a style="color: #f00" @click="handleDelete">删除</a>
        <a style="color: #E66306" v-if="value.status == 0" @click="handleCancel">取消订单</a>
        <a style="color: #00A2EA" v-if="value.status == 0" @click="handlePay">去付款</a>
        <a style="color: #E66306" v-if="value.status == 2" @click="handleView">查看物流</a>
        <a style="color: #E66306" v-if="value.status == 3" @click="handleApply">申请退货</a>
      </td>
    </tr>
    <!-- 正常订单 -->
    <tr class="order-detail" v-for="item,i in value.product" :key="i" v-if="value.product.length !== 0">
      <td>
        <div class="t-b-item1 clearfix">
          <div class="t-b-i-left">
            <img :src="item.ppic"/>
          </div>
          <div class="t-b-i-right">
            <div class="title">{{item.pname}}</div>
            <!-- <div class="description">史铁生是当代中国令人敬佩的作家之一。他的写作与他的生命完全同构在了一起，在自己的“写作之夜”，史铁生用残缺…</div> -->
          </div>
        </div>
      </td>
      <td style="color:#E66306;text-align:center;">
        ¥{{item.unit_price}}
      </td>
      <td style="text-align:center;">
        {{item.quantity}}
      </td>
      <td style="color:#E66306;text-align:center;" v-if="item.unit_price">
        ¥{{(item.unit_price * item.quantity).toFixed(2)}}
      </td>
      <td style="text-align: center;" v-if="i===0">
        {{value.status == 0 ? '待付款' : value.status == 1 ? '待发货' : value.status == 2 ? '待收货' : value.status == 3 ? '待评价' : '无效商品'}}
      </td>
      <td style="text-align: center;" v-if="i===0">
        <a style="color: #f00" @click="handleDelete">删除</a>
        <a style="color: #E66306" v-if="value.status == 0" @click="handleCancel">取消订单</a>
        <a style="color: #00A2EA" v-if="value.status == 0" @click="handlePay">去付款</a>
        <a style="color: #E66306" v-if="value.status == 2" @click="handleView">查看物流</a>
        <a style="color: #E66306" v-if="value.status == 3" @click="handleApply">申请退货</a>
      </td>
    </tr>
  </tbody>
</template>

<script>
import book1 from '@/assets/mock_images/book1.png'

export default {
  name: 'orderItem',

  data() {
    return {
      book1
    };
  },
  props: {
    value: {
      type: Object,
      default() { return { /*  */ } }
    }
  },
  methods: {
    handleDelete() {
      this.$emit('delete', this.value)
    },
    handleCancel() {
      this.$emit('cancel', this.value)
    },
    handleView() {
      this.$emit('view', this.value)
    },
    handleApply() {
      this.$emit('apply', this.value)
    },
    handlePay() {
      this.$emit('pay', this.value)
    }
  }
};
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
tbody.order-item{
  tr.order-info{
    background-color: #f4f4f4;
    line-height: 40px;
  }
  tr.order-detail{}
  td:first-child{
    width: 400px;
    .t-b-item1{
      padding: 20px 0;
      .t-b-i-left{
        float: left;
        >img{
          width: 90px;
          height: 90px;
        }

      }
      .t-b-i-right{
        float: left;
        width: 270px;
        margin-left: 10px;
        .title{
          color: #333;
          font-weight: 700;
        }
        .description{
          color: #666;
          font-size: 12px;
          line-height: 20px;
        }
      }
    }
  }
}
</style>